const MAP={
		'/record/create':'create()',	
		'/record/list':'list()',
		'/record/daily':'daily()',
		'/record/amend':'amend()',
		
	}
class JQProductController extends global.JQBaseController {
     constructor(url,conn,req_obj) {
		super(url,conn,req_obj);
	
       // super.name = name;
    }
	
	
	//生成订单
	async create(){
		console.log('product create 1111111');
		const service = global.JQService.instance(
			'record_service/create',this.conn,this.req_obj,this.params);
		let data =service.do_action();
		console.log('product create 222222');
		return data;
	}
	
	async list(){
		console.log('list::1111')
		let data_obj = this.req_obj.data_obj;
		if(!data_obj)data_obj={};
		let page = data_obj.page;
		console.log('list::2222')
		let page_size = data_obj.size;
		if(!page_size ||page_size<0)page_size=5;
		if(!page ||page<0)page=1;
		page--;
		page=page*page_size;
		console.log('list::33333')
		
		if(!data_obj.first || data_obj.first<=0)data_obj.first =page;
		data_obj.size=page_size;
		console.log('list::4444')
		this.req_obj.data_obj= data_obj;
		const service = global.JQService.instance(
			'record_service/list',this.conn,this.req_obj,this.params);
		let data =service.do_action();
		return data;
	}

    async daily(){
    	console.log('daily::1111')
    	let data_obj = this.req_obj.data_obj;
    	if(!data_obj)data_obj={};
    	let page = data_obj.page;
    	console.log('daily::2222')
    	let page_size = data_obj.size;
    	if(!page_size ||page_size<0)page_size=5;
    	if(!page ||page<0)page=1;
    	page--;
    	page=page*page_size;
    	console.log('daily::33333')
    	
    	if(!data_obj.first || data_obj.first<=0)data_obj.first =page;
    	data_obj.size=page_size;
    	console.log('daily::4444')
    	this.req_obj.data_obj= data_obj;
    	const service = global.JQService.instance(
    		'record_service/daily',this.conn,this.req_obj,this.params);
			
			console.log('daily::5555')
    	let data =await service.do_action();
		console.log('daily::6666')
    	return data;
    }
    
	async amend(){
		console.log('amend::1111')
		let data_obj = this.req_obj.data_obj;
		if(!data_obj)data_obj={};
		let page = data_obj.page;
		console.log('amend::2222')
		let page_size = data_obj.size;
		if(!page_size ||page_size<0)page_size=5;
		if(!page ||page<0)page=1;
		page--;
		page=page*page_size;
		console.log('amend::33333')
		
		if(!data_obj.first || data_obj.first<=0)data_obj.first =page;
		data_obj.size=page_size;
		console.log('amend::4444')
		this.req_obj.data_obj= data_obj;
		const service = global.JQService.instance(
			'record_service/amend',this.conn,this.req_obj,this.params);
			
			console.log('amend::5555')
		let data =await service.do_action();
		console.log('amend::6666')
		return data;
	}
	
	
	
	
    async  dispatch() {
		super.dispatch();
		
		let req = this.req_obj;
		let func = MAP[this.url];
		
		if(func){
			console.log('dispatch'+ '  ' +  func);
			func = 'this.'+func;
			console.log('dispatch'+ '  ' +  func);
			let res_data = await eval(func);
			return res_data;
		}else return null;
		
		
    }
	
	
}
module.exports = JQProductController;